/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "comision")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Comision.findAll", query = "SELECT c FROM Comision c"),
    @NamedQuery(name = "Comision.findByIdCategoria", query = "SELECT c FROM Comision c WHERE c.comisionPK.idCategoria = :idCategoria"),
    @NamedQuery(name = "Comision.findByIdComision", query = "SELECT c FROM Comision c WHERE c.comisionPK.idComision = :idComision"),
    @NamedQuery(name = "Comision.findByFechaVigencia", query = "SELECT c FROM Comision c WHERE c.fechaVigencia = :fechaVigencia"),
    @NamedQuery(name = "Comision.findByValor", query = "SELECT c FROM Comision c WHERE c.valor = :valor"),
    @NamedQuery(name = "Comision.findByDescripcion", query = "SELECT c FROM Comision c WHERE c.descripcion = :descripcion")})
public class Comision implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ComisionPK comisionPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fechaVigencia")
    @Temporal(TemporalType.DATE)
    private Date fechaVigencia;
    @Basic(optional = false)
    @NotNull
    @Column(name = "valor")
    private int valor;
    @Size(max = 100)
    @Column(name = "descripcion")
    private String descripcion;
    @JoinColumn(name = "idCategoria", referencedColumnName = "idCategoria", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Categoria categoria;

    public Comision() {
    }

    public Comision(ComisionPK comisionPK) {
        this.comisionPK = comisionPK;
    }

    public Comision(ComisionPK comisionPK, Date fechaVigencia, int valor) {
        this.comisionPK = comisionPK;
        this.fechaVigencia = fechaVigencia;
        this.valor = valor;
    }

    public Comision(int idCategoria, int idComision) {
        this.comisionPK = new ComisionPK(idCategoria, idComision);
    }

    public ComisionPK getComisionPK() {
        return comisionPK;
    }

    public void setComisionPK(ComisionPK comisionPK) {
        this.comisionPK = comisionPK;
    }

    public Date getFechaVigencia() {
        return fechaVigencia;
    }

    public void setFechaVigencia(Date fechaVigencia) {
        this.fechaVigencia = fechaVigencia;
    }

    public int getValor() {
        return valor;
    }

    public void setValor(int valor) {
        this.valor = valor;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Categoria getCategoria() {
        return categoria;
    }

    public void setCategoria(Categoria categoria) {
        this.categoria = categoria;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (comisionPK != null ? comisionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comision)) {
            return false;
        }
        Comision other = (Comision) object;
        if ((this.comisionPK == null && other.comisionPK != null) || (this.comisionPK != null && !this.comisionPK.equals(other.comisionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Comision[ comisionPK=" + comisionPK + " ]";
    }
    
}
